<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>

<body>
<div id="app">
  <input v-model="message">
  <p>{{message}}</p>
  <button @click="resule">添加</button>
  <p v-for="(item,index) in List " :key="index">
    <span>{{item}}</span>
    <button @click="handleRemove(index)">移除</button>
  </p>
  <span v-if="flag">总数:{{List.length}}</span>
</div>
<script> 
var app = new Vue({
  el: '#app',
  data: {
    message: '',
    flag:false,
    List:[]
  },
  methods: {
      resule:function(){
        if(this.message){
          this.List.push(this.message);
      if(this.List.length>0){
        this.flag=true;
        }
      }
    },
    handleRemove: function(index) {
            this.List.splice(index, 1)  
      }
   }
})
</script>
</body>
</html>